package com.pet.controller;

import com.pet.utils.OssTemplate;
//import com.whd.system.util.Result;
//import com.whd.system.util.VodTemplate;
import com.pet.utils.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Objects;

@RestController
@Api(tags = "视频上传控制器")
@RequestMapping("/lovePet/system/upload")
@CrossOrigin  // 解决跨域问题
public class UpladController {

    @Autowired
    private OssTemplate ossTemplate;



    // 上传图片
    @RequestMapping(value = "/uploadImage")
    public Result uploadImage(MultipartFile uploadImage) throws IOException {

        String imageUrl = this.ossTemplate.upload(Objects.requireNonNull(uploadImage.getOriginalFilename()), uploadImage.getInputStream());

        System.out.println(imageUrl);
        return Result.ok(imageUrl);
    }

}